package com.situ.cloud.order.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.situ.cloud.order.dto.ProductDTO;
import com.situ.cloud.order.entity.OrderDetail;
import com.situ.cloud.order.entity.OrderInfo;
import com.situ.cloud.order.feign.ProductFeign;
import com.situ.cloud.order.mapper.OrderDetailMapper;
import com.situ.cloud.order.mapper.OrderInfoMapper;
import com.situ.cloud.order.service.IOrderInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author kkkkkk
 * @since 2023-10-20
 */
@Service
public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo> implements IOrderInfoService {

    @Autowired
    private OrderDetailMapper orderDetailMapper;

    @Autowired
    private ProductFeign productFeign;

    @Override
    public OrderInfo info(Integer id) {
        //根据订单信息查询这个订单中商品信息
        OrderInfo oi = baseMapper.selectById(id);

        List<OrderDetail> list = orderDetailMapper.selectList(new LambdaQueryWrapper<OrderDetail>().eq(OrderDetail::getOrderId, oi.getId()));

        for(OrderDetail od : list){
            Integer pid = od.getProductId();

            ProductDTO p = productFeign.selectById(pid);

            System.out.println(p);
        }

        return oi;
    }
}
